﻿@model CodingWiki_Model.ViewModels.BookAuthorVM

<div class="container p-3 border">
    <div class="row">
        <div class="col-6 form-group">
            <form method="post" action="ManageAuthors" class="row">
                <div asp-validation-summary="ModelOnly" class="text-danger"></div>
                <input type="hidden" asp-for="Book.BookId" />
                <input type="hidden" asp-for="BookAuthor.Book_Id" />

                <div class="col-4 py-2">
                    <label asp-for="Book.Title"></label>
                </div>
                <div class="col-8 py-2">
                    <input type="text" asp-for="Book.Title" class="form-control" disabled />
                </div>
                <div class="col-4 py-2">
                    <label asp-for="BookAuthor.Author.FullName"></label>
                </div>
                <div class="col-8 py-2">
                    @Html.DropDownListFor(u => u.BookAuthor.Author_Id, Model.AuthorList, "--Select Author--",
                    new { @class = "form-select" })
                </div>
                <div class="col-4 offset-4 py-2">
                    <button type="submit" class="btn btn-primary form-control">Add Association</button>
                </div>
                <div class="col-4 py-2">
                    <a asp-action="Index" class="btn btn-success form-control">Back to List</a>
                </div>
            </form>
        </div>
        <div class="col-6">

            <form method="post" action="RemoveAuthors">
                <input type="hidden" asp-for="@Model.Book.BookId" />
                <div class="row text-right  py-2">
                    <div class="col-12 text-right h4 text-primary">
                        Authors Associated to this Book:
                    </div>
                </div>
                @foreach (var auth in Model.BookAuthorList)
                {

                    <div class="row  py-2">
                        <div class="col-8 text-right" style="font-size:23px;">@auth.Author.FullName</div>
                        <div class="col-4">
                            <button asp-action="RemoveAuthors" type="submit" class="btn btn-danger form-control" asp-route-authorId="@auth.Author_Id">Remove</button>
                        </div>
                    </div>
                }
            </form>
        </div>
    </div>

</div>


@section Scripts{
    <partial name="_ValidationScriptsPartial" />
}